package com.yh.patterns.observer.job;

import java.util.ArrayList;

/**
 * @Author:云尚
 * @Description:抽象主题类
 */
public abstract class Team {
    //战队名称
    protected String teamName;
    //定义一个集合用于存储战队成员
    protected ArrayList<Observer> players=new ArrayList<Observer>();

    public String getTeamName() {
        return teamName;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    //加入战队的方法
    public void join(Observer observer){
        System.out.println(observer.getName()+"加入"+this.teamName+"战队！");
        players.add(observer);
    }
    //退出战队的方法
    public void quit(Observer observer){
        System.out.println(observer.getName()+"退出"+this.teamName+"战队！");
        players.remove(observer);
    }
    //抽象通知方法
    public abstract void notify(String name);
}
